﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using Util.Domains;
using Util.Domains.Auditing;

namespace IterationLife.Domains.Sports.Models {
    /// <summary>
    /// 运动员
    /// </summary>
    [Description( "运动员" )]
    public partial class SportAthlete : AggregateRoot<SportAthlete>,IDelete,IAudited {
        /// <summary>
        /// 初始化运动员
        /// </summary>
        public SportAthlete() : this( Guid.Empty ) {
        }

        /// <summary>
        /// 初始化运动员
        /// </summary>
        /// <param name="id">运动员标识</param>
        public SportAthlete( Guid id ) : base( id ) {
            SportTeams = new List<SportTeam>();
            SportEventGroupPeople = new List<SportEventGroupPerson>();
            SportEventGroupPersonSections = new List<SportEventGroupPersonSection>();
        }

        /// <summary>
        /// 合作方运动员Id
        /// </summary>
        [Required(ErrorMessage = "合作方运动员Id不能为空")]
        [StringLength( 200, ErrorMessage = "合作方运动员Id输入过长，不能超过200位" )]
        public string PartnerAthleteId { get; set; }
        /// <summary>
        /// 姓名
        /// </summary>
        [StringLength(50, ErrorMessage = "身份证号输入过长，不能超过50位")]
        public string Name { get; set; }
        /// <summary>
        /// 身份证号
        /// </summary>
        [StringLength( 50, ErrorMessage = "身份证号输入过长，不能超过50位" )]
        public string IdCard { get; set; }
        /// <summary>
        /// 国籍
        /// </summary>
        [StringLength( 20, ErrorMessage = "国籍输入过长，不能超过20位" )]
        public string Nationality { get; set; }
        /// <summary>
        /// 性别
        /// </summary>
        [Required(ErrorMessage = "性别不能为空")]
        public int Sex { get; set; }
        /// <summary>
        /// 生日
        /// </summary>
        public DateTime? Birthday { get; set; }
        /// <summary>
        /// 身高cm
        /// </summary>
        public decimal? Stature { get; set; }
        /// <summary>
        /// 体重kg
        /// </summary>
        public decimal? Weight { get; set; }
        /// <summary>
        /// 历史平均数据
        /// </summary>
        public string HistoryAverageJsonData { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreationTime { get; set; }
        /// <summary>
        /// 创建人
        /// </summary>
        public Guid? CreatorId { get; set; }
        /// <summary>
        /// 最后修改时间
        /// </summary>
        public DateTime? LastModificationTime { get; set; }
        /// <summary>
        /// 最后修改人
        /// </summary>
        public Guid? LastModifierId { get; set; }
        /// <summary>
        /// 是否删除
        /// </summary>
        [Required(ErrorMessage = "是否删除不能为空")]
        public bool IsDeleted { get; set; }
        
        /// <summary>
        /// 体育队伍列表
        /// </summary>
        public virtual ICollection<SportTeam> SportTeams { get; set; }
        
        /// <summary>
        /// 体育比赛分组运动员列表
        /// </summary>
        public virtual ICollection<SportEventGroupPerson> SportEventGroupPeople { get; set; }
        
        /// <summary>
        /// 体育比赛分组个人分段列表
        /// </summary>
        public virtual ICollection<SportEventGroupPersonSection> SportEventGroupPersonSections { get; set; }
        
        /// <summary>
        /// 添加描述
        /// </summary>
        protected override void AddDescriptions() {
            AddDescription( "运动员编号", Id );
            AddDescription( "合作方运动员Id", PartnerAthleteId );
            AddDescription( "姓名", Name );
            AddDescription( "身份证号", IdCard );
            AddDescription( "国籍", Nationality );
            AddDescription( "性别", Sex );
            AddDescription( "生日", Birthday );
            AddDescription( "身高cm", Stature );
            AddDescription( "体重kg", Weight );
            AddDescription( "历史平均数据", HistoryAverageJsonData );
            AddDescription( "创建时间", CreationTime );
            AddDescription( "创建人", CreatorId );
            AddDescription( "最后修改时间", LastModificationTime );
            AddDescription( "最后修改人", LastModifierId );
        }
        
        /// <summary>
        /// 添加变更列表
        /// </summary>
        protected override void AddChanges( SportAthlete newEntity ) {
            AddChange( "Id", "运动员编号", Id, newEntity.Id );            
            AddChange( "PartnerAthleteId", "合作方运动员Id", PartnerAthleteId, newEntity.PartnerAthleteId );
            AddChange( "Name", "姓名", Name, newEntity.Name);
            AddChange( "IdCard", "身份证号", IdCard, newEntity.IdCard );
            AddChange( "Nationality", "国籍", Nationality, newEntity.Nationality );
            AddChange( "Sex", "性别", Sex, newEntity.Sex );
            AddChange( "Birthday", "生日", Birthday, newEntity.Birthday );
            AddChange( "Stature", "身高cm", Stature, newEntity.Stature );
            AddChange( "Weight", "体重kg", Weight, newEntity.Weight );
            AddChange( "HistoryAverageJsonData", "历史平均数据", HistoryAverageJsonData, newEntity.HistoryAverageJsonData );
            AddChange( "CreationTime", "创建时间", CreationTime, newEntity.CreationTime );
            AddChange( "CreatorId", "创建人", CreatorId, newEntity.CreatorId );
            AddChange( "LastModificationTime", "最后修改时间", LastModificationTime, newEntity.LastModificationTime );
            AddChange( "LastModifierId", "最后修改人", LastModifierId, newEntity.LastModifierId );
        }
    }
}